package com.kevin.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 配置文件加载类
 * @author Kevin
 */
public class ConfigUtil {
	static Properties prop=new Properties();
	final static String file_separator=System.getProperty("file.separator");
	static{
		try {
			String dir=System.getProperty("exe.path");
			dir=dir+"config.properties";
			File file=new File(dir);
			InputStream in=null;
			if(file.exists()){
				 in=new FileInputStream(file);
			}else{
				 in=ConfigUtil.class.getClassLoader()
							.getResourceAsStream("config.properties");
			}
			prop.load(in);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static String get(String key){
		return prop.getProperty(key);
	}
	
	public static String get(String key,String def){
		return prop.getProperty(key,def);
	}

}
